﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Waker.Common;

namespace Waker.Records
{
    public partial class FormWagesRecord : Base.FormBaseToolBar
    {
        public FormWagesRecord()
        {
            InitializeComponent();
        }

        private void FormWages_Load(object sender, EventArgs e)
        {
            for (int i = DateTime.Now.Year - 10; i < 10; i++)
            {
                cbeWagesYear.Properties.Items.Add(i);
            }
            cbeWagesYear.EditValue = DateTime.Now.Year;
            for (int i = 1; i <= 12; i++)
            {
                cbeWagesMonth.Properties.Items.Add(i);
            }
            cbeWagesMonth.EditValue = DateTime.Now.Month;

            var dtSite = new BAL.BAL_Cards().GetAllDepartment();
            ckbListSubContractor.Properties.DataSource = dtSite;
            FormRefresh();
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            FormRefresh();
        }
        public override void FormRefresh()
        {
            var dt = new BAL.BAL_Records().WagesSearch(
                Convert.ToInt32(cbeWagesYear.EditValue)
                , Convert.ToInt32(cbeWagesMonth.EditValue)
                , ckbListSubContractor.EditValue == null ? string.Empty : ckbListSubContractor.EditValue.ToString().Trim()
                , txtEmp_Name.Text.Trim()
                , txtEmp_No.Text.Trim()
                , txtEmp_IDCard.Text.Trim()
                );
            this.gridControl1.DataSource = dt;
            if (gridView1.GroupCount > 0)
                gridView1.ExpandGroupRow(gridView1.FocusedRowHandle, false);
        }
    }
}
